package com.oracle.application.service.listener;
import com.alibaba.fastjson.JSONObject;
import com.oracle.application.entity.Logs;
import com.oracle.application.service.listener.service.LogsService;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class
LogsAddConsumer implements MessageListener {

    @Autowired
    private LogsService logsService;
    @Override
    public void onMessage(Message message) {
        //获取消息 调用  日志添加业务
        String jsonLog=new String(message.getBody());
        Logs log = JSONObject.parseObject(jsonLog,Logs.class);
        this.logsService.addLogs(log);
    }
}
